/** * @description : 待办文书中转页 * @descriptionDetail : 待办文书中转页 * @copyright : 浙江烟草 * @author : mc * @create : 2022-11-05 09:50:12 */
<template>
  <view class="page"></view>
</template>

<script>
import commonService from "@/service/common/common.service";
import linkageService from "@/service/internal/linkeage.service";
import { COMMON_DOC, processDefKeyByInternalToZmDb } from "@/service/enum/common-doc";
export default {
  onLoad(op) {
    let opt = this.getRouteParam() || {};
    this.taskId = opt.taskId || op.taskId;
			this.procStatus = opt.procStatus;
    this.bizCode = opt.bizCode;
    this.bizUuid = opt.bizUuid;
    this.gfCode = opt.processDefKey;
    this.prevParam = opt;
  },
  data() {
    return {
      prevParam: {},
      taskId: "",
      bizCode: "",
      bizUuid: "",
      gfCode: "",
				procStatus: "", // 死亡或丧失行为能力书面告知书待办&已办区分字段
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.$modal.showLoading("加载中...");
      commonService
        .getBizTaskConfigBybizCode({
          taskId: this.taskId,
          bizCode: this.bizCode,
          bizUuid: this.bizUuid,
          sysCode: this.prevParam.sysCode,
          menuCode: "",
        })
        .then((res) => {
          this.$modal.hideLoading();
          if (res.success) {
            this.doIntent(res.bean);
          } else {
            this.$u.toast(res.msg);
            this.error();
          }
        })
        .catch((e) => {
          // 中转失败
          this.$modal.hideLoading();
          this.$modal.alert("待办打开失败", () => {
            this.error();
          });
        });
    },
    doIntent(obj) {
      if (obj.mobileFormUrl == "pages/todo/commonDocPage") {
        // 如果存在gfcode 则表示是统一待办文书流程
        console.log(this.$u.test.object(COMMON_DOC[this.gfCode]), COMMON_DOC[this.gfCode], this.gfCode, "gfcode");
        if (this.$u.test.object(COMMON_DOC[this.gfCode])) {
          this.setRouteParam({
            docInsUuid: this.bizUuid,
            gfCode: this.gfCode,
          });
          this.$u.route({
            url: "/pages/todo/commonDocPage",
            type: "redirect",
          });
        } else {
          this.$modal.alert("该待办尚未在移动端支持,请在PC端处理", () => {
            this.error();
          });
        }
      } else if (obj.mobileFormUrl == "pages/todo/docInternal") {
        if (processDefKeyByInternalToZmDb.indexOf(this.gfCode) != -1) {
          this.setRouteParam({
            docInsUuid: this.bizUuid,
            gfCode: this.gfCode,
          });
          this.$u.route({
            url: "/pages/todo/commonDocPage",
            type: "redirect",
          });
        } else {
          this.$u.route({
            url: "pages/todo/docInternal",
            params: {
              bizUuid: this.bizUuid,
            },
            type: "redirect",
          });
        }
      } else if (obj.mobileFormUrl == "pages/todo/storeDoc") {
        // 如果存在gfcode 则表示是统一待办文书流程
        if (this.$u.test.object(COMMON_DOC[this.gfCode])) {
          this.setRouteParam({
            taskId: this.taskId,
            bizUuid: this.bizUuid,
            gfCode: this.gfCode,
            bizCode: this.bizCode,
          });
          this.$u.route({
            url: "/pages/todo/storeDoc",
            type: "redirect",
          });
        } else {
          this.$modal.alert("该待办尚未在移动端支持,请在PC端处理", () => {
            this.error();
          });
        }
      } else {
        // 用来表示是统一待办文书 则表示是自定义的流程 需要跳转到自定义页面去
        if (this.$u.test.isEmpty(obj.mobileFormUrl)) {
          this.$modal.alert("正在开发中...", () => {
            this.error();
          });
        } else {
          obj.taskId = this.taskId;
          obj.bizUuid = this.bizUuid;
          obj.gfCode = this.gfCode;
          obj.bizCode = this.bizCode;
          obj.bizCode = this.bizCode;
          // obj.processDefKey = this.prevParam.processDefKey;
					obj.procStatus = this.procStatus;
          this.setRouteParam(obj);
          if (this.bizCode == "task-check") {
            this.$modal.showLoading("页面加载中...");
            // 由于这里要判断退回重新编辑页面，所以要调用此接口 zyf start 2024-2-4
            linkageService
              .getTaskClientDetail(obj.bizUuid)
              .then((res) => {
                this.$modal.hideLoading();
                if (res.success) {
                  if (res.bean && res.bean.currentHanlderCode == "0" && res.bean.step == "edit") {
                    this.$u.route({
                      url: "/pages/internal/linkage/todo/informationEntryAddUpdate",
                      type: "redirect",
                      params: {
                        id: obj.bizUuid,
                        operateType: "approve",
                        isStatus: 1,
                      },
                    });
                  } else {
                    this.$u.route({
                      url: obj.mobileFormUrl,
                      type: "redirect",
                    });
                  }
                } else {
                  this.$modal.hideLoading();
                  this.$modal.alert("待办打开失败", () => {
                    this.error();
                  });
                }
              })
              .catch((err) => {
                this.$modal.hideLoading();
                this.$modal.alert("待办打开失败", () => {
                  this.error();
                });
              });
            // 由于这里要判断退回重新编辑页面，所以要调用此接口 zyf end 2024-2-4
          } else {
            this.$u.route({
              url: obj.mobileFormUrl,
              type: "redirect",
            });
          }
        }
      }
    },
    error() {
      uni.navigateBack();
    },
  },
};
</script>

<style scoped lang="scss">
.page {
  padding: 0;
  background-color: white;
}
</style>
